package calao.util;

import java.io.File;
import java.io.IOException;

public class Files 
{
	
	/** Deletes a file.
	 * If the file is a directory, recursively deletes all files in this directory.
	 */
	public static boolean delete(File file) 
	{
		if (file.isDirectory()) {
			for (File child : file.listFiles()) {
				if (!delete(child)) return false;
			}
		}
		return file.delete();
	}

	public static File createTempDirectory(String prefix)
	throws IOException
	{
		File dir = File.createTempFile(prefix, null);		
		dir.delete();
		dir.mkdir();
		return dir;
	}

}
